﻿using System.Windows.Input;

namespace Present.Commands.Fluent
{
    public abstract class CommandBuilder<TCommand, TParameter> where TCommand : ICommand
    {
        public void Execute(TParameter parameter)
        {
            ((TCommand) this).Execute(parameter);
        }
        
        public static implicit operator TCommand(CommandBuilder<TCommand, TParameter> builder)
        {
            return builder.BuildCommand();
        }

        public TCommand ToCommand()
        {
            return BuildCommand();
        }

        protected abstract TCommand BuildCommand();
    }
}